<? 
class block_server_clock extends block_list {
    // The init() method does not need to change at all

    function init() {
	    //$this->title = "Server Clock";
	    $this->title = get_string('serverclock', 'block_server_clock');
	    $this->tagline = get_string('tagline', 'block_server_clock');
	    $this->months = get_string('months', 'block_server_clock');
	    $this->dateformat = get_string('dateformat', 'block_server_clock');
        $this->version = 2008110600;
	}
	
	function preferred_width() {
    // The preferred value is in pixels
    return 200;
}

function get_content() {
    if ($this->content !== NULL) {
        return $this->content;}
    

	

	global $CFG;

$this->content->items[] = "
<center>
<script type='text/javascript'>

// Current Server Time script (SSI or PHP)- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use.

//Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below your page supports and COMMENT the one it does not:
//Default is that SSI method is uncommented, and PHP is commented:

var currenttime = '".date('F d, Y H:i:s', time())."' //PHP method of getting server date

//var currenttime = '<!--#config timefmt='%B %d, %Y %H:%M:%S'--><!--#echo var='DATE_LOCAL' -->' //SSI method of getting server date
//var currenttime = '<? print date('F d, Y H:i:s', time())?>' //PHP method of getting server date

///////////Stop editting here/////////////////////////////////

".$this->months."

var serverdate=new Date(currenttime)

function padlength(what){
var output=(what.toString().length==1)? '0'+what : what
return output
}

function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
".$this->dateformat."
var timestring=padlength(serverdate.getHours())+':'+padlength(serverdate.getMinutes())+':'+padlength(serverdate.getSeconds())
document.getElementById('servertime').innerHTML=datestring+'<br />'+timestring
}

window.onload=function(){
setInterval('displaytime()', 1000)
}

</script>
<p><b>".$this->tagline."</b><br> <span id='servertime'></span></p>
</center>";
return $this->content;
}
}
?>



